var workerStats = {
  "workers" : {
    "fenghua-cloud" : {
      "id" : "fenghua-cloud",
      "ip" : "60.12.23.60",
			"enabled": true,
      "fetchedTasks" : 23,
      "confirmedTasks" : 23,
      "doubleConfirmedTasks" : 0,
      "lastAccess" : "2015-10-20T19:57:06.462"
    },
    "fenghua-cloud111" : {
      "id" : "fenghua-cloud111",
      "ip" : "60.12.23.60",
			"enabled": false,
      "fetchedTasks" : 23,
      "confirmedTasks" : 23,
      "doubleConfirmedTasks" : 0,
      "lastAccess" : "2015-10-20T19:57:06.462"
    }
  },
  "restart" : {
    "resetNum" : 0,
    "totalResetNum" : 0,
    "lastAccess" : "2015-10-20T12:01:47.478"
  }
};

var reporting = {
  "queueLength" : 0,
  "reporting" : 0,
  "successTimes" : 0,
  "failTimes" : 0,
  "stalledHashLength" : 0
};

module.exports = function(app) {
  var express = require('express');
  var loginStateRouter = express.Router();

  loginStateRouter.get('/workerstats', function(req, res) {
		res.json(workerStats);
  });

  loginStateRouter.get('/reportstats', function(req, res) {
    res.json(reporting);
  });

  loginStateRouter.get('/workerstats/toggle', function(req, res) {
		var wid = req.query.wid,
				wk = workerStats.workers[wid];
		console.log(wk);
		wk.enabled = !wk.enabled;
		res.json(workerStats);
  });

  app.use('/mconsolejs', loginStateRouter);
};
